<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <router-link to="/user/1">用戶1</router-link>
    <router-link to="/user/2">用戶2</router-link>
    <router-link to="/user/3">用戶3</router-link>
    <router-view></router-view>
  </div>
</body>
<script src="../lib/vue.js"></script>
<script src="./lib/vue-router.js"></script>
<script>
  // 组件定义
  var User = {
    props: ['id'],
    template: `<div>这是用户功能{{id}}<input/></div>`,
    watch: {
      id(id){
        console.log(id)
      }
    }
  };

  // 设置路由规则
  var routes = [
    {
      path: '/user/:id',
      component: User,
      props: true
    }
  ]
  var router = new VueRouter({
    routes
  })

  var vm = new Vue({
    el: '#app',
    router
  })
</script>
</html>